import axios from "../utils/axios.js"
export let getList = ()=>{ // 这个方法名就是组件里的this.props.getList
    return (dispatch)=>{
        axios.get("/list").then(res=>{
            dispatch({
                type:"getList",
                payload:res.data.list
            })
        })
    }
}
// 删除的方法
export let delFN = (data)=>{
    return {
        type:"delFN",
        payload:data
    }   
}
// 增加得方法
export let addfn = (data)=>{
    return {
        type:"addfn",
        payload:data
    }
}
export let editFn = (data)=>{
    return {
        type:"editFn",
        payload:data
    }
}
export let searchfn = (data)=>{
    return {
        type:"searchfn",
        payload:data
    }
}
export const getPushList = (mode) => {
    return (dispatch) => {
        axios.get('/pushData').then(res => {
            console.log(res);
            dispatch({
                type: "getPushList",
                payload: res.data,
                mode
            })
        })
    }
}
export const getPullList = (mode)=>{
    return (dispatch)=>{
        axios.get("/pushData").then(res=>{
            dispatch({
                type:"getPullList",
                payload:res.data,
                mode
            })
        })
    }
}